package com.tanhua.server.controller;

import com.tanhua.model.vo.*;
import com.tanhua.server.service.TanhuaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 交友模块控制层
 */
@RestController
@RequestMapping("/tanhua")
public class TanhuaController {

    @Autowired
    private TanhuaService tanhuaService;

    /**
     * 今日佳人
     */
    @RequestMapping(value = "/todayBest",method = RequestMethod.GET)
    public ResponseEntity todayBest(){
        TodayBestVo todayBestVo = tanhuaService.todayBest();
        return ResponseEntity.ok(todayBestVo);
    }

    /**
     * 推荐朋友
     */
    @RequestMapping(value = "/recommendation",method = RequestMethod.GET)
    public ResponseEntity recommendation(RecommendUserVo recommendUserVo){
        PageResult<TodayBestVo> bestVoPageResult = tanhuaService.recommendation(recommendUserVo);
        return ResponseEntity.ok(bestVoPageResult);
    }

    /**
     * 佳人信息
     */
    @RequestMapping(value = "/{personId}/personalInfo",method = RequestMethod.GET)
    public ResponseEntity personalInfo(@PathVariable("personId") Long personId){
        TodayBestVo todayBestVo  = tanhuaService.personalInfo(personId);
        return ResponseEntity.ok(todayBestVo);
    }


    /**
     * 查询陌生人问题
     */
    @RequestMapping(value = "/strangerQuestions",method = RequestMethod.GET)
    public ResponseEntity strangerQuestions(Long userId){
        String content  = tanhuaService.strangerQuestions(userId);
        return ResponseEntity.ok(content);
    }

    /**
     * 回复陌生人问题
     */
    @RequestMapping(value = "/strangerQuestions",method = RequestMethod.POST)
    public ResponseEntity replyStrangerQuestions(@RequestBody Map params){
        tanhuaService.replyStrangerQuestions(params);
        return ResponseEntity.ok(null);
    }


    /**
     * 探花推荐列表查询
     */
    @RequestMapping(value = "/cards",method = RequestMethod.GET)
    public ResponseEntity cards(){
        List<TodayBestVo> todayBestVoList =  tanhuaService.cards();
        return ResponseEntity.ok(todayBestVoList);
    }

    /**
     * 探花-喜欢(右滑)
     */
    @RequestMapping(value = "/{likeUserId}/love",method = RequestMethod.GET)
    public ResponseEntity love(@PathVariable("likeUserId") Long likeUserId){
        tanhuaService.love(likeUserId,true);
        return ResponseEntity.ok(null);
    }

    /**
     * 探花-不喜欢（左滑）
     */
    @RequestMapping(value = "/{likeUserId}/unlove",method = RequestMethod.GET)
    public ResponseEntity unlove(@PathVariable("likeUserId") Long likeUserId){
        tanhuaService.love(likeUserId,false);
        return ResponseEntity.ok(null);
    }

    /**
     * 搜附近
     */
    @RequestMapping(value = "/search",method = RequestMethod.GET)
    public ResponseEntity searchNearBy(String gender, Long distance){
        List<NearUserVo> list =  tanhuaService.searchNearBy(gender,distance);
        return ResponseEntity.ok(list);
    }
}
